home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Float calculations
- Date: 02 Feb 1996 18:26:54 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb2112654@qcd.lanl.gov>
- References: <4eqssf$d9q@camelot.ccs.neu.edu> <DM458u.F1y@microunity.com>
- <DM5AtL.C24@uns.bris.ac.uk>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: nathan@pact.srf.ac.uk's message of Fri, 2 Feb 1996 11:05:44 GMT
-
- In article <DM5AtL.C24@uns.bris.ac.uk> nathan@pact.srf.ac.uk (Nathan
- Sidwell) writes:
- <snip>
- for instance
- float a;
- double b, c;
-
- b = 99974.0/50.0;
- a = b;
- c = a;
-
- a and b will be different (provided a's been stored), but
-
- Actually, there is no requirement that double is more precise or in
- any way different than float. But most modern machines do make a
- distinction.
-
- will c be equal to a or to b?
-
- I believe that the standard does require c to be equal to
- a. Optimizations are disallowed in C if they have any visible effect,
- unless specifically permitted by the standard: and almost the only
- thing that the standard permits is to hold intermediate results _while
- evaluating an expression_ in higher precision. Even there, a footnote
- advises that the semantics of a cast and assignment would lead to
- truncation. In short, C is not a language in which I would like to do
- large scale numerical calculations.
-
- Fortunately many compilers accept correct C code and allow me to
- specify (by commission or ommission) that I want the compiler to
- compile my code wrong in such controlled ways.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-